﻿@model IEnumerable<L006_Manage.Models.Task>

@{
    ViewBag.Title = "Index";
}

<h2>主页</h2>

<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.TaskPriority)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Content)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AddTime)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.TaskState)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FinishedTime)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.uid)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @{string str = "";
                    if (item.TaskPriority == 1)
                    {
                        str= "高";
                        
                    }
                    else if (item.TaskPriority == 2)
                    {
                        str= "中";
                    }
                    else
                    {
                        str= "低";
                    }
                }
                @str
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Content)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.AddTime)
            </td>
            <td>
                @(item.TaskState==1?"未完成":"完成")
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FinishedTime)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.uid)
            </td>
            <td>
                @Html.ActionLink("修改", "Edit", new { id = item.TaskID }) |
                @Html.ActionLink("详情", "Details", new { id = item.TaskID }) |
                <a del="@item.TaskID">删除</a>
                @*@Html.ActionLink("删除", "Index", new { id=item.TaskID },new { del=item.TaskID})*@

            </td>
        </tr>
    }

</table>
@section scripts{
    <script type="text/javascript">
        $(function Delete() {
            $("a[del]").click(function () {
                var $this = $(this)//保存this
                var id = $(this).attr("del"); // 获取选中行id
                if (!confirm("确定要删除" + id + "吗？"))
                    return;
                $.post("Delete", { id, id }, function (result) {
                    if (result) {
                        $this.closest("tr").remove();//删除选中行
                        alert("删除成功");
                    }
                })
            })
        })


    </script>

}
